﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Timers;
using System.Threading;


namespace CashCommon
{
    delegate void SetTextCallback(string text);

    public partial class FrmProgress : Form
    {
        public FrmProgress(String caption)
        {
            InitializeComponent();
            this._timer.Elapsed += new ElapsedEventHandler(Ontimer_Elapsed);
            this._timer.Enabled = true;
            this.FormCaption = caption;
        }
        private FrmProgress() { }


        private void Ontimer_Elapsed(object sender, ElapsedEventArgs e)
        {
            this._currentTime = this._currentTime.AddMilliseconds(100);
            this.SetText(this._currentTime.ToString("mm:ss:ff"));
        }
        public void SetText(string text)
        {
            if (this.label2.InvokeRequired)
                BeginInvoke(new MethodInvoker(delegate
                   {
                       label2.Text = text;
                   }));
            else
                label2.Text = text;
        }


        private System.Timers.Timer _timer = new System.Timers.Timer(100);
        private DateTime _currentTime;

        private void FrmProgress_Load(object sender, EventArgs e)
        {
            labelTitle.Text = FormCaption;
            labelTitle.TextAlign = ContentAlignment.MiddleCenter;
            _currentTime = new DateTime(0, 0);
        }

        public string FormCaption { get; set; }

        private void btnClose_Click(object sender, EventArgs e)
        {
            this.Close();
        }  
    }
}
